<?php

namespace app\health\model;

use think\Model;

class HealthGoodsAttr extends Model
{
    // 表名
    protected $name = 'health_goods_attr';
    protected $autoWriteTimestamp = false;

    protected $append = ['image_url'];


    /**
     * 定义商品表相对关联
     * @Author 张旭鹏
     * @DateTime 2023-06-15
     */
    public function goods()
    {
        return $this->belongsTo(HealthGoods::class, 'goods_id');
    }

    /**
     * 获取完整图片链接
     * @param [type] $value
     * @param [type] $data
     * @Author 张旭鹏
     * @DateTime 2023-06-14
     */
    public function getImageUrlAttr($value, $data)
    {
        return isset($data['image']) ? cdnurl($data['image'], true) : '';
    }
}
